#ifndef _TANKDATA_H_
#define _TANKDATA_H_

// tank shape is made of hull, turret and gun:

//   hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
//   h            ttttttt           h
//   h           t       t          h
//   h          t    ggggggggggggggggggggg
//   h           t       t          h
//   h            ttttttt           h
//   hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

// only hull (as a rectangle) and gun (as a line) are used in colission detection

// server has a database of tank types.
// when game is set up, server receives tank type from client
// and builds a table of tanks in the current game.
// then the table is sent to all clients. from this point on,
// the tanks will be identified by their index in the table.
// update messages will contain minimal info: tank index, coordinates of
// hull center, hull angle, turret angle, speed

// tank orientation (front/rear) is obtained from hull angle:
// - an angle of 0 means the tanks is facing east (like the
// image above)
// - an angle of 90 means the tanks is facing north (the image
// from above rotated with 90 degrees counter-clockwise)
// - an angle of 180 means the tank is facing west
// - an angle of 270 means the tanks is facing south

// same goes for gun orientation.
// gun angle is also absolute (not relative to hull angle)

typedef struct {
  int x;
  int y;
} Point;

typedef struct {
  int width;
  int height;
} Size;

typedef struct {
  int left;
  int top;
  int right;
  int bottom;
} Rectangle;

typedef struct {
  Point origin;
  int length;
} Line;

// element type for static content array
typedef struct {
  Size hullSize;
  Point turretCenter;
  int turretRadius;
  Line gun;
  int maxForwardSpeed;
  int maxReverseSpeed;
  int maxHealth;
} TankType;

// element type of dynamic content array
typedef struct {
  Point hullCenter; // coordinates of hull center
  int hullAngle;
  int turretAngle;
  int speed; // current speed, negative speed means going backward
  int health; // zero health means dead
} TankPosition;

#endif
